package logic

import (
	"context"
	"math/rand"
	"time"
	"zy1_user/models/cache"
	"zy1_user/userRpc/internal/svc"
	"zy1_user/userRpc/userRpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
	return &SendSmsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SendSmsLogic) SendSms(in *userRpc.SendSmsRequest) (*userRpc.SendSmsResponse, error) {
	// todo: add your logic here and delete this line

	code := rand.Intn(9000) + 1000
	
	cache.Rdb.Set(l.ctx, "sendSms"+in.Mobile, code, time.Minute*5)

	return &userRpc.SendSmsResponse{}, nil
}
